using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MimeCloud.AssetManagement.Business.Interface;

namespace MimeCloud.AssetManagement.AssetRendering.Metadata
{
    /// <summary>
    /// Interaction logic for MetadataItem.xaml
    /// </summary>
    public partial class MetadataItem : UserControl
    {
        public MetadataItem()
        {
            InitializeComponent();
            
        }

        private IMetaData _selectedData;

        public IMetaData SelectedData
        {
            get
            {
                return _selectedData;
            }
            set
            {
                _selectedData = value;
                LanguageDisplay.Text = _selectedData.MetaValue.Language.LanguageCode;
                ValueDisplay.Text = _selectedData.MetaValue.Value;
            }
        }

        private void UserControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
            //show editing dialog
            MetadataValueEditorDialog dlg = new MetadataValueEditorDialog();
            dlg.MetadataValue = _selectedData;
            if (dlg.ShowDialog()==true)
            {
                _selectedData.MetaValue.Value = dlg.AlteredValue;
                SelectedData = _selectedData;
            }
        }
    }
}
